<?
	include("../main_inc.php");
	
	if($_POST['Submit']){
		
		$m= new AddToDatabase();
		$m->AddPosts($_POST,$_FILES);
		$m->AddTable("affiliateDomains");
		$m->AddExtraFields(array("affiliateID"=>$_SESSION['AffKey']));
		$m->DoStuff();
		$NewID=$m->ReturnID();
		$Message="Domain Added";
		
	};
	
	if($_POST['Delete']=="Delete"){
		if(is_array($_POST['DFiles'])){
			$m= new BulkDBChange();
			$m->AddIDArray($_POST['DFiles']);
			$m->WhatToChange("Active","No");
			$m->AddTable("affiliateDomains");
			$Errors=$m->DoChange();
			
			if($Errors==""){
				$Message="Domains Deleted";
			}else{
				$Message=$Errors;
			};
		}else{
			$Message="No Domains Selected To Delete";
		};
	};

?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Bubble Affiliate Program</title>

<link href="../../css/admin.css" rel="stylesheet" type="text/css">
<script src="../../jscript/menuArrayAffiliate.php" language="javascript"></script>
<script src="../../jscript/clock.js" language="javascript"></script></head>

<body onLoad="funClock();">
<?php include("../header.php"); ?>
<table width="100%" border="0" cellspacing="25" cellpadding="0">
<tr>
<td valign="top" width="240"><div id="menu"><?php include("../menu.php"); ?></div></td>
<td valign="top" align="center">

<?=$Message;?>
<div id="titleCompact">Add Domain </div>
<div id="contentCompact">
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#E9EEF5">
<tr id="formHeader">
<td><strong>Enter Domain Name  </strong><strong></strong></td>
</tr>
<tr>
  <td align="center" bgcolor="#FFFFFF"><form name="form1" method="post" action="domains.php">
    <table width="400" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td width="130" height="30">Domain Name:</td>
        <td width="354"><input name="domain" type="text" class="formFields" id="domain" size="40"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="Submit" value="Add Domain" class="formButtonSubmit"></td>
      </tr>
    </table>
      </form>
  </td>
</tr>
</table>
</div>
<br>
<div id="titleCompact">Domain List </div>
<div id="contentCompact">
  <form name="form2" method="post" action="domains.php">
    <table width="600" border="0" cellpadding="5" cellspacing="1" bgcolor="#E9EEF5">
      <tr id="formHeader">
        <td><strong>Domain Name </strong></td>
        <td width="70" align="center"><strong>Delete</strong></td>
      </tr>
      <?php
	$Count=0;
	$r=new ReturnRecord();
	$sq2=$r->rawQuery("SELECT id,domain FROM affiliateDomains WHERE affiliateID=$_SESSION[AffKey]  AND Active='Yes'");  
	while ($myrow = mysql_fetch_row($sq2)) {
?>
      <tr bgcolor="<?=(($Count%2)==0 ? "#FFFFFF" : "#EBEBEB"); ?>">
        <td><?=$myrow[1];?></td>
        <td align="center"><input type="checkbox" name="DFiles[]" value="<?=$myrow[0];?>"></td>
      </tr>
      <?
		$Count++;
	};
?>
      <tr>
        <td bgcolor="#FFFFFF">&nbsp;</td>
        <td align="center" bgcolor="#FFFFFF"><input name="Delete" type="submit" id="Delete" value="Delete" class="formButtonSubmit"></td>
      </tr>
    </table>
      </form>
  </div>
</td>
</tr>
</table>
</body>
</html>
